package server.utils;

import server.views.servermngpanel.toppanel.TopPanel;

/**
 * 日志类
 * @author solomon
 *
 */
public class Log {

	private Class c = null;

	private Log(Class c) {
		this.c = c;
	}

	/**
	 * 返回日志对象.
	 * 
	 * @param c
	 *            调用日志类的类.
	 * @return 日志对象.
	 */
	public static Log getInstance(Class c) {
		return new Log(c);
	}

	/**
	 * 记录日志.
	 * 
	 * @param e
	 *            异常对象.
	 */
	public void log(Throwable e) {
		System.out.println("类[" + c.getName() + "]  " + e.getMessage());
		TopPanel tp = new TopPanel();
		tp.getDetailJt().append("类[" + c.getName() + "]  " + e.getMessage());
		tp.getDetailJt().append("\n");
		//e.printStackTrace();
	}

	/**
	 * 记录日志.
	 * 
	 * @param str
	 *            日志描述.
	 */
	public void log(String str) {
		System.out.println("类[" + c.getName() + "]  " + str);
		TopPanel tp = new TopPanel();
		tp.getDetailJt().append("类[" + c.getName() + "]  " + str);
		tp.getDetailJt().append("\n");
	}
}
